from database_util import get_daily_report_info
from os import system
from daily_report_auto_db import start
from time import sleep
from datetime import datetime
from random import randint

if __name__ == '__main__':
    print('**************UESTC自动每日健康填报程序**************')
    try:
        while True:
            users = get_daily_report_info()
            for user in users:
                print(">>> 填报人：%s" % user[1])
                start(user_id=user[0], stu_num=user[2], password=user[3], email=user[4])
                sleep(randint(30, 40))
            print("check information... %s >>>" % datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
            sleep(7200)
    except Exception as e:
        print(e)
        system("python main.py")
    finally:
        input('> 按任意键退出')
